home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / sbf3.zip / DMA.TXT < prev    next >
Text File  |  1992-11-30  |  3KB  |  89 lines

  1. Programming PC DMA Controller (8237)
  2. Josh Cohen
  3. CSC 390 Special Topics
  4. H. Barada
  5.  
  6.     The process, described in detail later, for programming DMA
  7. transfers is somewhat complex.  
  8.  
  9. General Steps:
  10.  
  11. Set up a buffer to read from or write to.
  12. Disable the channel you wish to set up.
  13. Set the Page Register to the page which you want to transfer.
  14. Clear the Byte Pointer.
  15. Set Base Address register to the address of the beginning of the buffer.
  16. Set the Base Word Count register to number of words you wish to transfer.
  17. Set the DMA transfer Mode.
  18. Enable DMA channel to start transfer.
  19.  
  20. Details    
  21.  
  22. Registers of the 8237 DMA controller
  23.     The DMA controller has several channels.  Channel 1 is best for
  24. user transfers as some others are used by the system.
  25.  
  26. Address    Description
  27. 00Ah    Channel mask (enable/disable)
  28. 083h    Page Register
  29. 00Ch    Clear Byte pointer flipflop
  30. 002h    Base Address 16 bit register
  31. 003h    Base Word count 16 bit register
  32. 00Bh    Transfer mode register
  33.  
  34. To set up DMA controller
  35.  
  36. Set up a buffer to read from or write to.
  37. Since the DMA controller does everything in 64k blocks, it is best to
  38. try to align the buffer to the segment edge, I.e. Segment A offset 0.
  39. This can be difficult depending on the language which we use.
  40.  
  41. Disable the channel you wish to set up.
  42. If we use channel 1 we send 05h to address 00A (page register)
  43.  
  44. Set the Page Register 00A to the page which you want to transfer.
  45. The pages are 64k blocks in main memory.  We must setup multiple
  46. transfers if we wish to transfer more than 64k since the controller is
  47. only able to do 64k at a time.
  48. The pages are 00h to FFh starting with 0000-FFFF.  Notice that these are
  49. the same pages that we call segments.  When we specify addresses we are
  50. only talking about the offsets from the segment, not the entire address.
  51.  
  52. Clear the Byte Pointer.
  53. The clear byte pointer register is a flip flop.  Writing to the register
  54. clears it, the actual data which we write is ignored.
  55. Write any value to 00Ch
  56.  
  57. Set Base Address register to the address of the beginning of the buffer.
  58. To do this we write the offset from the segment edge of the starting
  59. address of our buffer, this will be 0 if we have aligned the buffer to
  60. the segment edge.
  61. Write this offset to 002h
  62.  
  63. Set the Base Word Count register to number of words you wish to transfer.
  64. This register gets the number of words which we wish to transfer. 
  65. Usually this will be bytes.  
  66. Write this number to 003h
  67.  
  68. Set the DMA transfer Mode.
  69. This register controls the mode of transfer, it will vary upon the
  70. device which we want to transfer to.  In our case, using the
  71. ThunderBoard Sound Card the possible modes are:
  72. 49h  Non-continuous playback
  73. 59h  Continuous playback
  74. 45h  Non-continous record
  75. 55h  Continuous record
  76. By playback we mean transfer data from memory out to the card
  77. By record we mean transfer data from the card to memory.
  78. Notice that we are sending out or receiving data from the bus.  The
  79. computer really does not care or know where the data is going or coming
  80. from.  We must also set up the device we are transferring with.  In this
  81. case it is the ThunderBoard.  See the next document on how to do that.
  82.  
  83. Enable DMA channel to start transfer.
  84. Now that we have correctly set up the DMA controller for the transfer,
  85. we can enble the channel.  However, we must set up the card to receive
  86. or send the data first.  Usually, in practice, the card is set up before
  87. the DMA controller.
  88.  
  89.